#! /usr/bin/python

hexa = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']

digit3 = set()
dd = [0 for i in range(9)]
counter = 4
readyll = [0 for i in range(17)]
for i in range(0, 16):
    for j in range(0, 16):
	if i == 0: break
	for k in range(0, 16):	    
	    digit3.add((hexa[i], hexa[j], hexa[k]))
	    if set([hexa[i], hexa[j], hexa[k]]) == set(['0', '1','A']):
		print hexa[i], hexa[j], hexa[k]
		readyll[3] += 1
		continue
	    dd.append([hexa[i], hexa[j], hexa[k]])

print len(dd)

def nextDigit(current, readyll, length):
    newll = []
    for i in range(len(current)):
        ll = [x for x in current[i]]
	for a in hexa:
	    ll.append(a)
	    if ll.count('0') >= 1 and ll.count('1') >= 1 and ll.count('A') >= 1: 
	       readyll[length] += 1
	       #print ll
	       ll = [x for x in current[i]]
               continue
	    newll.append(ll)
	    ll = [x for x in current[i]]
    return newll, readyll

for i in range(4, 5):
    dd, readyll = nextDigit(dd, readyll, i)

print readyll
print len(readyll)



